<%@ page language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>钱包-提现记录管理</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <jsp:include page="../com/header.jsp"></jsp:include>
    <script type="text/javascript" src="../../js/comm/listcomm.js"></script>
    <script type="text/javascript">
        var contentUrl = root + "cms/walletWithdrawRecord/findWalletWithdrawRecordNEStatusPage";
        var editUrl = 'walletWithdrawRecordEdit.jsp?id=';
        var operateUrl = root + 'cms/walletWithdrawRecord/operateWalletWithdrawRecordByIds';
        var withdrayOnAlipayUrl = root + 'cms/walletWithdrawRecord/batchTransByAliPay';//支付宝提现
        function getfilter() {
            var _jsonFilter = "{";
            if ($("#search_userId").val() && $("#search_userId").val().length > 0) {
                _jsonFilter += "'search_EQ_userId':'" + $("#search_userId").val().replace("'", "\"") + "',";
            }
            if ($("#search_withdrawMoney").val() && $("#search_withdrawMoney").val().length > 0) {
                _jsonFilter += "'search_EQ_withdrawMoney':'" + $("#search_withdrawMoney").val().replace("'", "\"") + "',";
            }
            if ($("#search_withdrawStatus").val() && $("#search_withdrawStatus").val().length > 0) {
                _jsonFilter += "'search_EQ_withdrawStatus':'" + $("#search_withdrawStatus").val().replace("'", "\"") + "',";
            }
            if (_jsonFilter != "{") {
                _jsonFilter = _jsonFilter.substring(0, _jsonFilter.length - 1);
            }
            _jsonFilter += "}";
            return _jsonFilter;
        }

        $(document).ready(function () {
            //批量提现处理
            $("#withdrawSome").click(function () {
                var checkError = false;
                var delArray = [];
                $(".ckSelect").each(function () {
                    var check = $(this).is(':checked');
                    if (check) {
                        var _id      = $(this).attr("ckId");
                        var _wStatus = $(this).attr("ckWithdrawStatus");
                        if (_wStatus != 0) {
                            checkError = true;
                            return;
                        }
                        delArray.push(_id);
                    }
                });
                if (checkError) {
                    myAlert("只有提现申请中才可以进行处理");
                    return;
                }
                if (delArray.length == 0) {
                    myAlert("请选择要提现的项");
                    return;
                }
                myConfirm("<a href='https://110.alipay.com/cert/manage.htm' target='_blank'>提现浏览器需安装支付宝数组证书，请知晓！</a>", function () {
                    myConfirm("处理完成后，请稍等3-5min，否则会造成不必要的损失", function () {
                        $.ajax({
                            url: withdrayOnAlipayUrl,
                            type: 'post',
                            data: {
                                modelIds: delArray.join(",")
                            },
                            dataType: 'json',
                            success: function (data) {
                                if (data.code == 1) {
                                    if (data.object.length > 20) {
                                        $("#alipay_withdraw").html(data.object);
                                    } else  {
                                        myAlert(data.object);
                                    }
                                    dipscontent(getfilter(), contentUrl);
                                    $("#_selectAll").attr("checked", false);
                                } else {
                                    myAlert(data.msg);
                                }
                            }
                        });
                    })
                });
            });
        });

    </script>
</head>
<body>

<%--支付宝批量转账--%>
<div id="alipay_withdraw"></div>

<section>
    <div>
        <div class="col-xs-12">
            <div class="box">
                <form id="search_form" class="form-horizontal">
                    <div class="tabSelect" id="selectHeadId">
                        <br>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">提现用户：</label>
                            <div class="col-md-8">
                                <input type="text" placeholder="提现用户" class="form-control input-sm" id="search_userId"
                                       name="userId"/>
                            </div>
                        </div>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">提现状态：</label>
                            <div class="col-md-8">
                                <select class="form-control input-sm" id="search_withdrawStatus" name="withdrawStatus">
                                    <option value="">请选择</option>
                                    <option value="0">提现申请中</option>
                                    <option value="1">提现完成</option>
                                    <option value="2">提现关闭</option>
                                </select>
                            </div>
                        </div>
                        <input type="button" value="查询" id="search" class="btn btn-primary searchBtn">
                    </div>
                </form>
                <div class="box-body table-responsive" style="clear:both;">
                    <input type="button" value="提现处理" id="withdrawSome" class="btn btn-color">
                    <input type="button" value="删除" id="deleteSome" class="btn btn-danger">
                </div>
                <div class="box-body table-responsive">
                    <table id="example2" class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th width="30"><input type="checkbox" id="_selectAll"/></th>
                            <th width="80">提现用户</th>
                            <th width="80">提现交易号</th>
                            <th width="80" style="text-align: right">提现金额</th>
                            <th width="80">提现状态</th>
                            <th width="80">支付宝账号</th>
                            <th width="80">支付宝账号真实姓名</th>
                            <th width="120">备注信息</th>
                            <th width="80">操作完成时间</th>
                            <th width="20">状态</th>
                        </tr>
                        </thead>
                        <!-- 表格内容 start -->
                        <tbody id="mycontent"></tbody>
                        <!-- 表格内容 end -->
                    </table>
                    <!-- 分页标签 start -->
                    <div class="row page_big_div" id="displayPage"></div>
                    <!-- 分页标签 end -->
                    <script id="tableContentTmple" type="text/x-jsrender">
								<tr>
									<td><input id="ck_{{:id}}" ckId="{{:id}}" ckStatus="{{:status}}" class="ckSelect" type="checkbox" ckWithdrawStatus="{{:withdrawStatus}}" /></td>
									<td>{{:user.userName}}</td>
									<td>{{:withdrawTradeNo}}</td>
									<td style="text-align: right">{{toThousands:withdrawMoney}}</td>
									<td>{{if withdrawStatus==0}}提现申请中{{else withdrawStatus==1}}提现完成{{else}}提现关闭{{/if}}</td>
									<td>{{:aipayAccount}}</td>
									<td>{{:alipayUsername}}</td>
									<td title="{{:remark}}">{{splits:remark separators='^' indexs=5}}</td>
									<td>{{:withdrawSucessTime}}</td>
									<td>{{if status==1}}正常{{else status==2}}已发布{{else status==3}}已删除{{else status==-1}}已锁定{{else}}无效{{/if}}</td>
								</tr>
                    </script>
                </div>
            </div>
        </div>
</section>
</body>
</html>